package com.wxxymakers.cklabrecruit.mapper;

import com.wxxymakers.cklabrecruit.entity.EmailReturn;
import com.wxxymakers.cklabrecruit.entity.EmailReturnExample;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface EmailReturnMapper {

    @Update({"update email_return set resends = resends + 1 where Id = #{id}"})
    int addReSendNum(Integer id);

    //////////////
    long countByExample(EmailReturnExample example);

    int deleteByExample(EmailReturnExample example);

    @Delete({
        "delete from email_return",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into email_return (reg_id, record_id, ",
        "status, resends, datetime)",
        "values (#{regId,jdbcType=INTEGER}, #{recordId,jdbcType=INTEGER}, ",
        "#{status,jdbcType=BIT}, #{resends,jdbcType=INTEGER}, #{datetime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(EmailReturn record);

    int insertSelective(EmailReturn record);

    List<EmailReturn> selectByExample(EmailReturnExample example);

    @Select({
        "select",
        "Id, reg_id, record_id, status, resends, datetime",
        "from email_return",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("com.wxxymakers.cklabrecruit.mapper.EmailReturnMapper.BaseResultMap")
    EmailReturn selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") EmailReturn record, @Param("example") EmailReturnExample example);

    int updateByExample(@Param("record") EmailReturn record, @Param("example") EmailReturnExample example);

    int updateByPrimaryKeySelective(EmailReturn record);

    @Update({
        "update email_return",
        "set reg_id = #{regId,jdbcType=INTEGER},",
          "record_id = #{recordId,jdbcType=INTEGER},",
          "status = #{status,jdbcType=BIT},",
          "resends = #{resends,jdbcType=INTEGER},",
          "datetime = #{datetime,jdbcType=TIMESTAMP}",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(EmailReturn record);
}